﻿using System;
using Phoenix.Framework;
using Xunit;

namespace Phoenix.Tests.Framework
{
    public class ControllerActionParameterTests
    {
        [Fact]
        public void matches_value_type()
        {
            // arrange
            var param = ControllerActionParameter.FromObject(1);

            // act
            var result = param.IsMatch(typeof (int));

            // assert
            Assert.True(result);
        }

        [Fact]
        public void does_not_match_null_to_value_type_parameter()
        {
            // arrange
            var param = ControllerActionParameter.FromObject(null);

            // act
            var result = param.IsMatch(typeof(int));

            // assert
            Assert.False(result);
        }

        [Fact]
        public void matches_reference_type()
        {
            // arrange
            var param = ControllerActionParameter.FromObject(new SomeClass());

            // act
            var result = param.IsMatch(typeof(SomeClass));

            // assert
            Assert.True(result);
        }

        [Fact]
        public void matches_reference_type_to_null_value()
        {
            // arrange
            var param = ControllerActionParameter.FromObject(null);

            // act
            var result = param.IsMatch(typeof(SomeClass));

            // assert
            Assert.True(result);
        }

        public class SomeClass
        {}
    }
}